package com.xxzb.pack0720;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class DemoA {
    public static void main(String[] args) {
        Connection conn;
        //1.加载驱动文件
        try {
            Class.forName("com.mysql.jdbc.Driver");
            //2.建立java和数据库之间的链接
            String url="jdbc:mysql:///gaofeng2207?useSSL=false";
            String username="root";
            String password="1234";
            conn= DriverManager.getConnection(url,username,password);
            //3.创建一个传令官，负责将java中的SQL语句发送到mysql中执行
            Statement statement=conn.createStatement();
            String sql="insert into gaofeng2207.emp values(null,'洪晨晨','程序员',7788,'2022-7-20',12800,300,30,1)";
            int row=statement.executeUpdate(sql);
            System.out.println(row+"行收到影响!");
            //4.关闭链接
            statement.close();
            conn.close();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        catch (SQLException throwables) {
            throwables.printStackTrace();
        }




    }
}
